﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;
using TomShane.Neoforce.Controls;

namespace Warlock.Menu
{
    class SingleOrMultiplayerMenu : IGameScreen
    {
        public Game1 MainGame { get; set; }

        Window window;
        Button spButton;
        Button mpButton;

        public void Initialize(GraphicsDeviceManager graphics, ContentManager content)
        {
            window = new Window(Game1.Manager);
            window.Init();
            window.Text = "";
            window.Width = graphics.PreferredBackBufferWidth;
            window.Height = graphics.PreferredBackBufferHeight;
            window.Left = 0;
            window.Top = 0;
            window.Movable = false;

            spButton = new Button(Game1.Manager);
            spButton.Init();
            spButton.Width = 200;
            spButton.Height = 50;
            spButton.Left = graphics.PreferredBackBufferWidth / 2 - spButton.Width / 2;
            spButton.Top = graphics.PreferredBackBufferHeight / 2 - 100;
            spButton.Text = "Singleplayer";
            spButton.Click += new TomShane.Neoforce.Controls.EventHandler(spButton_Click);
            spButton.Parent = window;

            mpButton = new Button(Game1.Manager);
            mpButton.Init();
            mpButton.Width = spButton.Width;
            mpButton.Height = spButton.Height;
            mpButton.Left = spButton.Left;
            mpButton.Top = graphics.PreferredBackBufferHeight / 2 + 100;
            mpButton.Text = "Multiplayer";
            mpButton.Click += new TomShane.Neoforce.Controls.EventHandler(mpButton_Click);
            mpButton.Parent = window;

            Game1.Manager.Add(window);
        }

        void mpButton_Click(object sender, TomShane.Neoforce.Controls.EventArgs e)
        {
            MultiPlayerConnectScreen mpConnectScreen = new MultiPlayerConnectScreen();
            ((Game1)(Game1.Manager.Game)).SwitchGamescreen(mpConnectScreen);
        }

        void spButton_Click(object sender, TomShane.Neoforce.Controls.EventArgs e)
        {
        }

        public void UnloadContent()
        {
            Game1.Manager.Remove(window);
            window.Dispose();
        }

        public void Update(GameTime gameTime)
        {
            Game1.Manager.Update(gameTime);
        }

        public void Draw(SpriteBatch spriteBatch, GameTime gameTime)
        {
            Game1.Manager.Draw(gameTime);
        }
    }
}